
package org.soderiakelvy.model.services.testCase;

import static org.junit.Assert.*;

import java.util.List;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;
import org.soderiakelvy.model.domain.PackVO;
import org.soderiakelvy.model.domain.ProductoVO;
import org.soderiakelvy.model.domain.SujetoVO;
import org.soderiakelvy.model.domain.TipoProductoVO;
import org.soderiakelvy.model.service.ProductoServicio;
import org.soderiakelvy.model.service.SujetoServicio;
import org.soderiakelvy.model.service.imp.ProductoServicioImp;
import org.soderiakelvy.model.service.imp.SujetoServicioImpl;
import org.soderiakelvy.model.util.ConstantModel;

public class TestPacks {
	//@BeforeClass

	
	@Test
	public void testPacksCrud(){
		
		ProductoServicio ps = new ProductoServicioImp();
		PackVO pVO = new PackVO();
		ProductoVO proVO = new ProductoVO();
		
		proVO = ps.getProductoById(1);
		
		pVO.setNombre("testNombre");
		pVO.setProducto(proVO);
		pVO.setDescripcion("----");
		pVO.setPrecioBidon((float)10);
		pVO.setPrecioPack((float)10);
		pVO.setCantidad(10);
		
		
		//----------- TEST  ALTA DE UN PACK    ------------------
		Assert.assertEquals(ConstantModel.SUCCESS,ps.insertPackVO(pVO));
		System.out.println("TEST ALTA OK");
		//-----------------------------------------------------------------------------
		
		//----------- TEST UPDATE PACK-----------------------------
		pVO.setDescripcion("DESCRIPCION");
		Assert.assertEquals(ConstantModel.SUCCESS,ps.updatePackVO(pVO));
		System.out.println("TEST UPDATE OK");
		//-----------------------------------------------------------------------------
		
		//----------- TEST OBTENER UN PACK POR SU ID ------------------
		Assert.assertNotNull(ps.getPackById( pVO.getPackId()  ));
				
		System.out.println("TEST OBTENER UN  PACK OK");
		//-----------------------------------------------------------------------------
		
		
		
		//----------- TEST  GETALL PACK ------------------------
		List<PackVO> packs1 = ps.getPacks();
		Assert.assertEquals(packs1.size(), 4);
		for(PackVO p : packs1){
			System.out.println(p);
		}
		
		System.out.println("TEST GETALL OK");
		//-----------------------------------------------------------------------------
		
		//----------- TEST ELIMINACION DE UN PACK ------------------------
		Assert.assertEquals(ConstantModel.SUCCESS,ps.deletePackVO(pVO));
		System.out.println("TEST ELIMINAR OK");
		//-----------------------------------------------------------------------------

		
	}

}
